package com.androidx.p013lv.invention.adapter;

import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.APPLink;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.AdInfoBean;
import com.androidx.p013lv.base.bean.InventionBean;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.recycler.BaseRecyclerAdapter;
import com.androidx.p013lv.base.recycler.BaseRecyclerHolder;
import com.androidx.p013lv.base.service.AdClickService;
import com.androidx.p013lv.base.utils.LogUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.invention.C1069R;
import com.androidx.p013lv.invention.OnInventionType;
import com.androidx.p013lv.invention.view.FifteenView;
import com.androidx.p013lv.invention.view.FiveView;
import com.androidx.p013lv.invention.view.FourView;
import com.androidx.p013lv.invention.view.FourteenView;
import com.androidx.p013lv.invention.view.HorizonealView;
import com.androidx.p013lv.invention.view.OneView;
import com.androidx.p013lv.invention.view.SixView;
import com.androidx.p013lv.invention.view.SixteenView;
import com.androidx.p013lv.invention.view.ThirteenView;
import com.androidx.p013lv.invention.view.ThreeView;
import com.androidx.p013lv.invention.view.TodayView;
import com.androidx.p013lv.invention.view.TwentyView;
import com.androidx.p013lv.invention.view.TwoView;
import com.androidx.p013lv.invention.view.VarietyView;
import com.androidx.p013lv.invention.view.VideoView;
import com.youth.banner.Banner;
import com.youth.banner.indicator.RectangleIndicator;
import com.youth.banner.listener.OnBannerListener;
import java.util.ArrayList;
import java.util.List;

/* renamed from: com.androidx.lv.invention.adapter.AdapterInventionType */
public class AdapterInventionType extends BaseRecyclerAdapter<InventionBean, Holder> {
    double adHeight;
    double bannerHeight;
    int classifyId;
    private boolean clickLimit = true;
    String domain;
    Fragment fragment;
    int height;
    private long lastClickTime;
    List<AdInfoBean> listAd;
    OnInventionType onInventionType;

    public AdapterInventionType(Fragment fragment2, OnInventionType onInventionType2, int i, int i2, List<AdInfoBean> list) {
        this.fragment = fragment2;
        this.onInventionType = onInventionType2;
        this.classifyId = i;
        this.height = i2;
        this.listAd = list;
        this.bannerHeight = (double) (UiUtils.getWindowWidth() / 2);
        this.adHeight = (double) ((UiUtils.getWindowWidth() - UiUtils.dp2px(12)) / 2);
    }

    public void setDomain(String str) {
        this.domain = str;
    }

    public void MyHolder(Holder holder, int i) {
        holder.setData((InventionBean) this.list.get(i), i, getItemViewType(i));
    }

    public void onViewRecycled(Holder holder) {
        super.onViewRecycled((RecyclerView.ViewHolder) holder);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public int getItemViewType(int i) {
        if (i == 0) {
            return 0;
        }
        if (i == getItemCount() - 1) {
            return 100;
        }
        return ((InventionBean) this.list.get(i)).getType();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public Holder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view;
        LayoutInflater from = LayoutInflater.from(viewGroup.getContext());
        switch (i) {
            case 0:
                view = from.inflate(C1069R.C1074layout.item_invention_banner, viewGroup, false);
                break;
            case 1:
                view = from.inflate(C1069R.C1074layout.item_invention_one, viewGroup, false);
                break;
            case 2:
                view = from.inflate(C1069R.C1074layout.item_invention_two, viewGroup, false);
                break;
            case 3:
                view = from.inflate(C1069R.C1074layout.item_invention_three, viewGroup, false);
                break;
            case 4:
                view = from.inflate(C1069R.C1074layout.item_invention_four, viewGroup, false);
                break;
            case 5:
                view = from.inflate(C1069R.C1074layout.item_invention_five, viewGroup, false);
                break;
            case 6:
                view = from.inflate(C1069R.C1074layout.item_invention_six, viewGroup, false);
                break;
            case 7:
                view = from.inflate(C1069R.C1074layout.item_invention_ad, viewGroup, false);
                break;
            case 8:
            default:
                view = LayoutInflater.from(viewGroup.getContext()).inflate(C1069R.C1074layout.item_invention_no, viewGroup, false);
                break;
            case 9:
                view = from.inflate(C1069R.C1074layout.item_invention_today, viewGroup, false);
                break;
            case 10:
                view = from.inflate(C1069R.C1074layout.item_invention_variety, viewGroup, false);
                break;
            case 11:
                view = from.inflate(C1069R.C1074layout.item_invention_video, viewGroup, false);
                break;
            case 12:
                view = from.inflate(C1069R.C1074layout.item_invention_horizoneal, viewGroup, false);
                break;
            case 13:
            case 15:
                view = from.inflate(C1069R.C1074layout.item_invention_thirteen, viewGroup, false);
                break;
            case 14:
                view = from.inflate(C1069R.C1074layout.item_invention_fourteen, viewGroup, false);
                break;
            case 16:
                view = from.inflate(C1069R.C1074layout.item_invention_sixteen, viewGroup, false);
                break;
            case 17:
                view = from.inflate(C1069R.C1074layout.item_invention_seventen, viewGroup, false);
                break;
            case 18:
                view = from.inflate(C1069R.C1074layout.item_invention_eighteen, viewGroup, false);
                break;
            case 19:
                view = from.inflate(C1069R.C1074layout.item_invention_activity, viewGroup, false);
                break;
            case 20:
                view = from.inflate(C1069R.C1074layout.item_invention_twenty, viewGroup, false);
                break;
        }
        return new Holder(view, i);
    }

    /* access modifiers changed from: package-private */
    /* renamed from: com.androidx.lv.invention.adapter.AdapterInventionType$Holder */
    public class Holder extends BaseRecyclerHolder {

        /* renamed from: a */
        ImageView f247a;
        APPLink appLink;
        Banner banner;
        LinearLayout btn_more;
        FifteenView fifteenView;
        FiveView fiveView;
        FourView fourView;
        FourteenView fourteenView;
        HorizonealView horizonealView;
        ImageView ivActivity;
        ImageView iv_ad_cover;
        LinearLayout linearLayout;
        OneView oneView;
        RelativeLayout rl_ad;
        SixView sixView;
        SixteenView sixteenView;
        ThirteenView thirteenView;
        ThreeView threeView;
        TodayView todayView;
        TextView tv_title;
        TwentyView twentyView;
        TwoView twoView;
        VarietyView varietyView;
        VideoView videoView;

        public Holder(View view, int i) {
            super(view);
            switch (i) {
                case 0:
                    this.banner = (Banner) view.findViewById(C1069R.C1072id.banner);
                    break;
                case 1:
                    this.oneView = new OneView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 2:
                    this.twoView = new TwoView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 3:
                    this.threeView = new ThreeView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 4:
                    this.fourView = new FourView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 5:
                    this.fiveView = new FiveView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 6:
                    this.sixView = new SixView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 7:
                    this.iv_ad_cover = (ImageView) view.findViewById(C1069R.C1072id.iv_ad_cover);
                    RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(C1069R.C1072id.rl_ad);
                    this.rl_ad = relativeLayout;
                    ViewGroup.LayoutParams layoutParams = relativeLayout.getLayoutParams();
                    layoutParams.height = (int) AdapterInventionType.this.adHeight;
                    this.rl_ad.setLayoutParams(layoutParams);
                    break;
                case 9:
                    this.todayView = new TodayView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 10:
                    this.tv_title = (TextView) view.findViewById(C1069R.C1072id.tv_title);
                    this.btn_more = (LinearLayout) view.findViewById(C1069R.C1072id.btn_more);
                    this.f247a = (ImageView) view.findViewById(C1069R.C1072id.f190a);
                    break;
                case 11:
                case 18:
                    this.videoView = new VideoView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 12:
                case 17:
                    this.horizonealView = new HorizonealView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 13:
                    this.thirteenView = new ThirteenView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 14:
                    this.fourteenView = new FourteenView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 15:
                    this.fifteenView = new FifteenView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 16:
                    this.sixteenView = new SixteenView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
                case 19:
                    this.ivActivity = (ImageView) view.findViewById(C1069R.C1072id.iv_bg_activity);
                    break;
                case 20:
                    this.twentyView = new TwentyView(view, AdapterInventionType.this.fragment, AdapterInventionType.this.domain, AdapterInventionType.this.onInventionType);
                    break;
            }
            if (i != 0 && i != 7 && i != 100) {
                this.linearLayout = (LinearLayout) view.findViewById(C1069R.C1072id.ll_item);
            }
        }

        public void setData(InventionBean inventionBean, int i, int i2) {
            if (this.linearLayout == null) {
                LogUtils.m63e("tasw", i2 + "<------------");
            }
            switch (i2) {
                case 0:
                    setBanner(AdapterInventionType.this.listAd, AdapterInventionType.this.domain);
                    return;
                case 1:
                    this.oneView.setView(inventionBean, i);
                    return;
                case 2:
                    this.twoView.setView(inventionBean, i);
                    return;
                case 3:
                    this.threeView.setView(inventionBean, i);
                    return;
                case 4:
                    this.fourView.setView(inventionBean, i);
                    return;
                case 5:
                    this.fiveView.setView(inventionBean, i);
                    return;
                case 6:
                    this.sixView.setView(inventionBean, i);
                    return;
                case 7:
                    final AdInfoBean adInfoBean = inventionBean.getAdInfoBean();
                    if (adInfoBean != null) {
                        LogUtils.m63e("disnwl", AdapterInventionType.this.domain + adInfoBean.getAdImage());
                        Fragment fragment = AdapterInventionType.this.fragment;
                        GlideUtils.loadCropRadius(fragment, AdapterInventionType.this.domain + adInfoBean.getAdImage(), 4, this.iv_ad_cover);
                        this.iv_ad_cover.setOnClickListener(new View.OnClickListener() {
                            /* class com.androidx.p013lv.invention.adapter.AdapterInventionType.Holder.View$OnClickListenerC11141 */

                            public void onClick(View view) {
                                Holder.this.clickAd(adInfoBean);
                            }
                        });
                        return;
                    }
                    return;
                case 8:
                default:
                    return;
                case 9:
                    this.todayView.setView(inventionBean, i);
                    return;
                case 10:
                    setImgBg(inventionBean, i, AdapterInventionType.this.domain, this.tv_title, this.btn_more, this.f247a);
                    return;
                case 11:
                case 18:
                    this.videoView.setView(inventionBean, i);
                    return;
                case 12:
                case 17:
                    this.horizonealView.setView(inventionBean, i);
                    return;
                case 13:
                    this.thirteenView.setView(inventionBean, i);
                    return;
                case 14:
                    this.fourteenView.setView(inventionBean, i);
                    return;
                case 15:
                    this.fifteenView.setView(inventionBean, i);
                    return;
                case 16:
                    this.sixteenView.setView(inventionBean, i);
                    return;
                case 19:
                    setActivityBg(inventionBean, i, AdapterInventionType.this.domain, this.ivActivity);
                    return;
                case 20:
                    this.twentyView.setView(inventionBean, i);
                    return;
            }
        }

        /* access modifiers changed from: package-private */
        public void setBanner(List<AdInfoBean> list, String str) {
            ViewGroup.LayoutParams layoutParams = this.banner.getLayoutParams();
            if (list == null || list.size() == 0) {
                list = new ArrayList<>();
                layoutParams.height = AdapterInventionType.this.height;
            } else {
                layoutParams.height = (int) AdapterInventionType.this.bannerHeight;
            }
            this.banner.setLayoutParams(layoutParams);
            this.banner.setIndicator(new RectangleIndicator(AdapterInventionType.this.fragment.getContext()));
            this.banner.setAdapter(new MyBannerAdapter(list, str, AdapterInventionType.this.fragment));
            this.banner.setOnBannerListener(new OnBannerListener() {
                /* class com.androidx.p013lv.invention.adapter.AdapterInventionType.Holder.C11152 */

                @Override // com.youth.banner.listener.OnBannerListener
                public void OnBannerClick(Object obj, int i) {
                    Holder.this.clickAd((AdInfoBean) obj);
                }
            });
        }

        /* access modifiers changed from: package-private */
        public void setImgBg(InventionBean inventionBean, int i, String str, TextView textView, LinearLayout linearLayout2, ImageView imageView) {
            if (inventionBean.getCoverImg() == null || TextUtils.isEmpty(inventionBean.getCoverImg())) {
                GlideUtils.loadCropRadiusDefault(4, imageView);
            } else {
                GlideUtils.loadCropRadiusWh2(str + inventionBean.getCoverImg(), 4, imageView, 600);
            }
            textView.setText(inventionBean.getStationName() + "");
            linearLayout2.setOnClickListener(new View.OnClickListener() {
                /* class com.androidx.p013lv.invention.adapter.AdapterInventionType.Holder.View$OnClickListenerC11163 */

                public void onClick(View view) {
                    if (!AdapterInventionType.this.isOnClick()) {
                        ARouter.getInstance().build(Constance.VARIETY_ACTIVITY).navigation();
                    }
                }
            });
            imageView.setOnClickListener(new View.OnClickListener() {
                /* class com.androidx.p013lv.invention.adapter.AdapterInventionType.Holder.View$OnClickListenerC11174 */

                public void onClick(View view) {
                    if (!AdapterInventionType.this.isOnClick()) {
                        ARouter.getInstance().build(Constance.VARIETY_ACTIVITY).navigation();
                    }
                }
            });
        }

        /* access modifiers changed from: package-private */
        public void setActivityBg(final InventionBean inventionBean, int i, String str, ImageView imageView) {
            if (inventionBean.getCoverImg() == null || TextUtils.isEmpty(inventionBean.getCoverImg())) {
                GlideUtils.loadCropRadiusDefault(4, imageView);
            } else {
                GlideUtils.loadCropRadiusWh2(str + inventionBean.getCoverImg(), 4, imageView, 600);
            }
            imageView.setOnClickListener(new View.OnClickListener() {
                /* class com.androidx.p013lv.invention.adapter.AdapterInventionType.Holder.View$OnClickListenerC11185 */

                public void onClick(View view) {
                    if (!AdapterInventionType.this.isOnClick()) {
                        if (inventionBean.getJumpType() == 2) {
                            try {
                                Intent intent = new Intent();
                                intent.setAction("android.intent.action.VIEW");
                                intent.setData(Uri.parse(inventionBean.getJumpUrl()));
                                AdapterInventionType.this.fragment.startActivity(intent);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                            if (Holder.this.appLink == null) {
                                Holder holder = Holder.this;
                                holder.appLink = new APPLink(AdapterInventionType.this.fragment.getContext());
                            }
                            Holder.this.appLink.urlLink(inventionBean.getJumpUrl());
                        }
                    }
                }
            });
        }

        /* access modifiers changed from: package-private */
        public void clickAd(AdInfoBean adInfoBean) {
            if (!AdapterInventionType.this.isOnClick() && adInfoBean != null) {
                if (adInfoBean.getJumpType() == 2) {
                    try {
                        Intent intent = new Intent();
                        intent.setAction("android.intent.action.VIEW");
                        intent.setData(Uri.parse(adInfoBean.getAdJump()));
                        AdapterInventionType.this.fragment.startActivity(intent);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    if (this.appLink == null) {
                        this.appLink = new APPLink(AdapterInventionType.this.fragment.getContext());
                    }
                    this.appLink.urlLink(adInfoBean.getAdJump());
                }
                Intent intent2 = new Intent(AdapterInventionType.this.fragment.getContext(), AdClickService.class);
                intent2.putExtra("adId", adInfoBean.getAdId());
                AdapterInventionType.this.fragment.getContext().startService(intent2);
            }
        }
    }

    /* access modifiers changed from: protected */
    public boolean isOnClick() {
        long currentTimeMillis = System.currentTimeMillis();
        long j = currentTimeMillis - this.lastClickTime;
        if (j > 1000) {
            this.lastClickTime = currentTimeMillis;
        }
        return !this.clickLimit ? j < 0 : j <= 1000;
    }
}
